Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake: version.h generation performed at build time #42527

Merged

Conversation

tejlmand
Copy link
Collaborator

@tejlmand tejlmand commented Feb 7, 2022

Fixes: #39503
Fixes: #40167

This commit moves BUILD_VERSION CMake variable from a compile
definition to be a define inside version.h.

Besides the benefit of having related settings grouped in a common
header, it also means that an updated BUILD_VERSION value does not
need to trigger re-compilation of all source files.

When using compile definitions, CMake cannot tell whether a given source
files uses the definition or not, and hence all sources must be
recompiled to be sure they are up-to-date.

Placing BUILD_VERSION in version.h, the source dependencies ensures
that only source files including version.h gets recompiled.

As part of this, version.h generation is moved so that it is now done
at build time.
This means that re-generation of version.h is no longer depending on a
CMake re-run but can have it's own dependency in .git/index when git
described is used to obtain BUILD_VERSION information.

Signed-off-by: Torsten Rasmussen Torsten.Rasmussen@nordicsemi.no

@tejlmand tejlmand added the bug The issue is a bug, or the PR is fixing a bug label Feb 7, 2022
@tejlmand tejlmand added this to the v3.0.0 milestone Feb 7, 2022
kernel/CMakeLists.txt Outdated Show resolved Hide resolved
Copy link
Collaborator

@SebastianBoe SebastianBoe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changes requested

@tejlmand tejlmand force-pushed the issues/40167_build_version branch 2 times, most recently from 70573c8 to 35b4092 Compare February 7, 2022 20:15
@tejlmand tejlmand added the DNM This PR should not be merged (Do Not Merge) label Feb 8, 2022
Fixes: zephyrproject-rtos#39503
Fixes: zephyrproject-rtos#40167

This commit moves `BUILD_VERSION` CMake variable from a compile
definition to be a define inside version.h.

Besides the benefit of having related settings grouped in a common
header, it also means that an updated `BUILD_VERSION` value does not
need to trigger re-compilation of all source files.

When using compile definitions, CMake cannot tell whether a given source
files uses the definition or not, and hence all sources must be
recompiled to be sure they are up-to-date.

Placing `BUILD_VERSION` in version.h, the source dependencies ensures
that only source files including `version.h` gets recompiled.

As part of this, version.h generation is moved so that it is now done
at build time.
This means that re-generation of version.h is no longer depending on a
CMake re-run but can have it's own dependency in `.git/index` when git
described is used to obtain `BUILD_VERSION` information.

Generation of logging dictionary database has been updated to support
BUILD_VERSION from header file instead of CMake configure time variable.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
@tejlmand tejlmand removed the DNM This PR should not be merged (Do Not Merge) label Feb 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Build System area: Kernel bug The issue is a bug, or the PR is fixing a bug
Projects
None yet
3 participants